import { ComboBox } from "../../../fl/controls/ComboBox";
import { IToolTipItem } from "../manager/IToolTipItem";
import { IFrUI } from "../core/IFrUI";
import { Global } from "../../gengine/global/Global";
import { ToolTipsManager } from "../manager/ToolTipsManager";
import { ObjEventListerTool } from "../utils/ObjEventListerTool";
import { InvalidationType } from "../../../fl/core/InvalidationType";
import { SkinManager } from "../skins/SkinManager";
import { UICompomentPool } from "../utils/UICompomentPool";
type int = number;
//class GComboBox
    
    export  class GComboBox extends ComboBox implements IToolTipItem, IFrUI
    {
        constructor()
        {
            
            super();this._styleName = this.CLASSNAME;
            this.addEventListener(flash.events.Event.ADDED_TO_STAGE, this.judgeToolTip);
            this.addEventListener(flash.events.Event.REMOVED_FROM_STAGE, this.judgeToolTip);
            return;
        }

        protected judgeToolTip(arg1: Object /* flash.events.Event */=null): void
        {
            if (arg1 && arg1.type == flash.events.Event.ADDED_TO_STAGE && this.toolTipData || !arg1 && this.toolTipData && Global.stage.contains(this)) 
            {
                ToolTipsManager.register(this);
            }
            else 
            {
                ToolTipsManager.unregister(this);
            }
            return;
        }

        public get toolTipData()
        {
            return this._toolTipData;
        }

        public set toolTipData(arg1)
        {
            this._toolTipData = arg1;
            this.judgeToolTip();
            return;
        }

        public configEventListener(arg1: string, arg2: Function, arg3: Boolean=false, arg4: int=0, arg5: Boolean=false): void
        {
            ObjEventListerTool.addObjEvent(this, arg1, arg2, arg3);
            addEventListener(arg1, arg2, arg3, arg4, arg5);
            return;
        }

        public /* override */ removeEventListener(arg1: string, arg2: Function, arg3: Boolean=false): void
        {
            ObjEventListerTool.removeObjEvent(this, arg1, arg2, arg3);
            super.removeEventListener(arg1, arg2, arg3);
            return;
        }

        protected final override configUI(): void
        {
            super.configUI();
            this.createChildren();
            return;
        }

        public get styleName(): string
        {
            return this._styleName;
        }

        public set styleName(arg1: string)
        {
            if (this._styleName != arg1) 
            {
                this._styleName = arg1;
                invalidate(InvalidationType.STYLES);
                this._isStyleChange = true;
            }
            return;
        }

        protected final override draw(): void
        {
            if (isInvalid(InvalidationType.STYLES)) 
            {
                if (this._isStyleChange) 
                {
                    SkinManager.setComponentStyle(this, this._styleName);
                    this._isStyleChange = false;
                }
                this.updateStyle();
            }
            if (isInvalid(InvalidationType.DATA)) 
            {
                this.updateDate();
            }
            if (isInvalid(InvalidationType.SIZE)) 
            {
                this.updateSize();
            }
            if (isInvalid(InvalidationType.SIZE, InvalidationType.SELECTED, InvalidationType.DATA)) 
            {
                this.updateDisplayList();
            }
            try 
            {
                super.draw();
            }
            catch (e)
            {
            };
            return;
        }

        protected createChildren(): void
        {
            return;
        }

        protected updateStyle(): void
        {
            return;
        }

        protected updateSize(): void
        {
            return;
        }

        protected updateDate(): void
        {
            return;
        }

        protected updateDisplayList(): void
        {
            return;
        }

        public set textColor(arg1: uint)
        {
            this.textField.textField.textColor = arg1;
            return;
        }

        public dispose(arg1: Boolean=true): void
        {
            ObjEventListerTool.delObjEvent(this);
            if (this.parent) 
            {
                this.parent.removeChild(this);
            }
            if (arg1) 
            {
                UICompomentPool.disposeUICompoment(this);
            }
            return;
        }

        public /* const */CLASSNAME: string="ComboBox";

        private /* var */_toolTipData;

        private /* var */_styleName: string;

        private /* var */_isStyleChange: Boolean=false;
    }
